<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>支付倒计时</title>
  <style>
      #jumpTo {
          color: orange;
          font-size: 24px;
      }
  </style>
</head>
<body>
<div>
  <h2>恭喜您，支付成功</h2>
  <span id="jumpTo">10</span>秒后自动跳转到首页
  <p>
    <button>立即返回</button>
  </p>


</div>
</body>
<script type="text/javascript">
  let btn = document.getElementsByTagName('button')[0];
  btn.onclick = function () {
    location.href = 'https://www.baidu.com'
  }
  //   加载页面时，倒计时
  window.onload = function () {
    let time = 10;
    let jumpTo = document.getElementById('jumpTo');
    let timer = setInterval(function () {
      time--;
      jumpTo.innerHTML = time;
      if (time === 0) {
        clearInterval(timer);
        location.href = 'https://www.baidu.com'
      }
    }, 1000)
  }
</script>
</html>